#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
Author       : Keyman
Date         : 2021-06-22 15:33:33
LastEditors  : Keyman
LastEditTime : 2021-06-22 21:58:49
"""

from typing import List

class Vector:
    """
    Represent a vector in multidimensional space
    """
    def __init__(self, d: int):
        """
        Create d-dimensional vector of zeros
        :param d: 
        :return : 
        """
        self._coords = [0] * d
    
    def __len__(self):
        """
        Return the dimensions of the vector
        """
        return len(self._coords)

    def __getitem__(self, j: int):
        """Return the jth coordinate of the vector"""
        return self._coords[j]

    def __setitem__(self, j: int, val: int):
        """Set the jth coordinate of the vector to given value"""
        if not isinstance(val, int):
            raise ValueError("Value must be an integer")
        return self._coords[j] = val

    def __add__(self, other: List):
        """Return sum of two vectors"""
        if len(self) != len(other):
            raise ValueError("dimensions must agree")
        result = Vector(len(self))
        for index in range(len(other)):
            result[index] = self[index] + other[index]
        return result


    def __eq__(self, other: List):
        """Return True if two vector has same coordinates as other"""
        return self._coords == other._coords

    def __ne__(self, other: List):
        """Return True if two vector differs from other"""
        return not self == other

    def __str__(self):
        return '<' + str(self._coords)[1:-1] + '>'  # adapt list representation
